unit oFrameStatistics;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, oManager, oProcessObjects, oStatisticProcessor,
  oStatisticEventConstants, oProcessItem, oscene, oProcessObjectConstants, Grids,
  ComCtrls, olevel, oEntity, oEntityTypeConstants, ImgList, ExtCtrls, TeeProcs,
  TeEngine, Chart, Series;

type
  TfStatistics = class(TFrame)
    memoStatistics: TMemo;
    Label1: TLabel;
    cbReplications: TComboBox;
    StringGrid: TStringGrid;
    tvStatObjects: TTreeView;
    iltTreeImage: TImageList;
    Button3: TButton;
    sdStatistic: TSaveDialog;
    Chart: TChart;
    Series1: TLineSeries;
    Series2: TBarSeries;
    Series3: TPieSeries;
    lTitle: TLabel;
    Label3: TLabel;
    rgValues: TRadioGroup;
    rbMean: TRadioButton;
    rbDispersion: TRadioButton;
    procedure chooseStatistic;
    procedure tvStatObjectsClick(Sender: TObject);
    procedure cbReplicationsChange(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure rbMeanClick(Sender: TObject);
    procedure rbDispersionClick(Sender: TObject);
  private
    aManager : TManager;
    { Private declarations }
  public
    { Public declarations }
    property Manager : TManager read aManager write aManager;
  end;

implementation

{$R *.dfm}

{ TfStatistics }

procedure TfStatistics.Button2Click(Sender: TObject);
begin
  chooseStatistic;
end;

procedure TfStatistics.Button3Click(Sender: TObject);
begin
  aManager.ProcessObject(TProcessItem.create(PO_EDITOR_STAT_SINGLE_SAVE, nil));
end;

procedure TfStatistics.cbReplicationsChange(Sender: TObject);
var
  i : Tinteger;
begin
  i := TInteger(cbReplications.Items.Objects[cbReplications.ItemIndex]);
  aManager.ProcessObject(
    TProcessItem.create(PO_EDITOR_STAT_SET_REPLICATION,
      TInteger.Create(i.Integer_
       )));
end;

procedure TfStatistics.chooseStatistic;
var
  j : integer;
  typ : integer;
  list : TProcessingList;
begin
  list := nil;
   begin

//    typ := TInteger(cbStatTypes.Items.Objects[cbStatTypes.ItemIndex]).Integer_;

    case typ of
      SE_WAITING_TIME_RESULT : begin
         list := TProcessingList.Create;
         list.addParameter(TInteger.Create(typ));
         aManager.ProcessObject(TProcessItem.create(PO_EDITOR_STAT_SHOW_STATISTIC,
            list));
      end;

      SE_PEOPLE_IN_MODEL_RESULT : begin
         list := TProcessingList.Create;
         list.addParameter(TInteger.Create(typ));
         aManager.ProcessObject(TProcessItem.create(PO_EDITOR_STAT_SHOW_STATISTIC,
            list));

      end;

      SE_PEOPLE_IN_ARRIVAL_RESULT : begin
         list := TProcessingList.Create;
         list.addParameter(TInteger.Create(typ));
         aManager.ProcessObject(TProcessItem.create(PO_EDITOR_STAT_SHOW_STATISTIC,
            list));

      end;
    end;
//    for j := 0 to TStatisticProcessor.getStatisticGroups.Count - 1 do
 //     cbStatGroups.AddItem(TStatisticProcessor.getStatisticGroups[j].Key,
  //      TInteger.Create(TStatisticProcessor.getStatisticGroups[j].Value));
  end;
end;

procedure TfStatistics.rbDispersionClick(Sender: TObject);
begin
  //chooseStatistic;
  aManager.ProcessObject(TProcessItem.create(PO_EDITOR_STAT_SHOW_STATISTIC, nil));
end;

procedure TfStatistics.rbMeanClick(Sender: TObject);
begin
  //chooseStatistic;
  aManager.ProcessObject(TProcessItem.create(PO_EDITOR_STAT_SHOW_STATISTIC, nil));
end;

procedure TfStatistics.tvStatObjectsClick(Sender: TObject);
var
  p : TPoint;
  node : TTreeNode;
begin
  GetCursorPos(P);
  P := tvStatObjects.ScreenToClient(P);
  node := TTreeview(sender).GetNodeAt(P.X, P.Y) ;
  if Assigned(node) and (node = tvStatObjects.Selected) then
  aManager.ProcessObject(TProcessItem.create(PO_EDITOR_STAT_TREE_CLICK,
    nil));
end;

end.
